package com.twu.biblioteca.menu;

import com.twu.biblioteca.*;

public class LogOutMenuItem implements MenuItem {
    @Override
    public String getName() {
        return "Log Out Of Your Account";
    }

    @Override
    public String getMnemonic() {
        return "lo";
    }

    @Override
    public PostMenuItemAction execute(Library library, UserIO io, UserRepository repository) {
        repository.logOut();

        io.println("Logged out successfully.");

        return PostMenuItemAction.Continue;
    }

    @Override
    public boolean shouldDisplay(User currentUser) {
        if (currentUser == null) {
            return false;
        } else {
            return true;
        }
    }

    @Override
    public int getPriority() {
        return MenuItem.PRIORITY_USERS;
    }
}
